<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/iconfont.css">
		<style>
			.mui-content-padded{margin:5px 0 0 0;}
			.mui-row-list span{float: left; line-height:33px; width:20%;}
			.mui-row-list select{float: left; line-height:14px; font-size:14px; margin-top:2px; margin-left: 5px;}
			.mui-btn-block{margin-bottom:0; padding:6px;}
			.mui-col-sm-12{ border-top: 1px solid #D1D1D1; width:100%; padding-top:5px; font-size:14px;}
			input[type="text"],input[type="number"]{height:26px; padding: 0;border-width:0;margin-bottom:0;background:none;}
			form:before{ background: none !important; border: none !important;}
			.mui-switch:before {content: '无'; color: #999;}
			.mui-switch.mui-active:before {content: '有'; color: #fff;}
			input{border-width:0; text-align: right; font-size:14px; line-height: 26px;}
			div{line-height: 26px;}
			.bottom_soild{border-bottom: 1px solid #DDDDDD; line-height: 26px;}
			.submit{
				margin:0 auto 10px auto; 
				width:200px; 
				height:35px; 
				line-height: 35px; 
				background-color:#007AFF; 
				text-align: center; 
				color: #FFFFFF; 
				border-radius: 10px;
				margin-top: 10px;
			}
			#Popup {
				width: 0px;
				height: 0px;
				background: red;
				position: fixed;
				top: 70%;
				left: 50%;
			}
			.mui-popover{
				width: 300px;
			}
			.mui-popover .mui-popover-arrow:after {
				width: 0px;
			}
			.mui-switch{
				border-color: #fd933b;
				background-color: #fd933b;
				border-width: 1px;
			}
			#mySwitch:before{content: '无';}
			#mySwitch.mui-active:before{content: '有';}
			#mySwitch2:before{content: '否';}
			#mySwitch2.mui-active:before{content: '是';}
			#mySwitch3:before{content: '否';}
			#mySwitch3.mui-active:before{content: '是';}
			.mui-switch:before {color: #fff; right: 10px;}
			.mui-switch.mui-active:before {color: #fff; left: 10px;}
			.mui-switch.mui-active {
				border-color: #007AFF;
				background-color: #007AFF;
			}
			.popover-cont ul{
				margin-top: 5px; 
				margin: 0; 
				padding: 0; 
				list-style: none; 
				background: #ffffff;
			}
			.table{
				width: 100%;
			}
			.thead{
				width: 100%;
				border: 1px solid #007AFF;
			}
			.thead tr{
				 width: 100%; 
				 background-color: #007AFF;
				 height: 20px;
			}
			.thead tr th{
				color: #ffffff;
				border-right: 1px solid #ffffff;
				text-align: center;
				font-family: "microsoft yahei";
				font-size: 14px;
				line-height: 20px;
			}
			.tbody{
				width: 100%;
				border: 1px solid #007AFF;
			}
			.tbody tr{
				 width: 100%; 
				 height: 20px;
			}
			.tbody tr td{
				color: #000;
				border: 1px solid #007AFF;
				text-align: center;
				font-family: "microsoft yahei";
				font-size: 14px;
				line-height: 20px;
			}
			.div-tab{
				width: 100%; 
				height: 200px; 
				overflow-y: scroll;
			}
			.div-tab::-webkit-scrollbar {
				display: none;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">其它信息</h1>
		</header>
		<div class="mui-conten" style="margin-top:50px;">
			<ul class="mui-table-view">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px;">服药依从性</div>
								<input id='medicine' class="ui-alert "  placeholder="请选择" style="width:50%; text-align: right; float: right; padding-right: 15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 16px;">药物不良反应</div>
							<div class="mui-switch" id="mySwitch">
							  <div class="mui-switch-handle"></div>
							</div>
						</li>
						<li class="mui-table-view-cell" style="display: none;" id="tigshow">
							<div style="float: left; font-size: 16px; width:5rem;">药物名称</div>
							<input class="ui-alert bottom_soild" id='medicinename'  placeholder="药物名称" style="width:50%; float: right;"/>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12 diabetes">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px;">低血糖反应</div>
								<input  id='lbstype' class="ui-alert"  placeholder="请选择" style="width:50%; text-align: right; float: right; padding-right: 15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px;">此次随访类型</div>
								<input  id='thetype' class="ui-alert"  placeholder="请选择" style="width:50%; text-align: right; float: right; padding-right: 15px;"/>
							</a>
						</li>
					</div>
				</div>
			</ul>
			<div style="margin-left:0.9rem; line-height:35px;">用药情况</div>
			<ul class="mui-table-view">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; width:100%;">
								<div style="float:left; font-size: 16px;">药物名称1</div>
								<input class="ui-alert bottom_soild" id="medicinename1" placeholder="请输入" style="width:60%; float: right;"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px;">每日次数</div>
								<div style="float:right; width:50px; font-size: 14px; text-align: right; padding-right: 20px;">次</div>
								<input id="daynum1" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每日"/>								
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px;">每次用量</div>
								<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="padding-right: 20px; float: right;">
									<input id='result3' class="ui-alert" placeholder="粒" style="width:30px; float: right; color:#000;"/>
								</a>
								<input id="num1" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每次"/>
							</div>
						</li>
					</div>
				</div>
			</ul>		
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; width:100%;">
								<div style="float:left; font-size: 16px;">药物名称2</div>
								<input class="ui-alert bottom_soild" id="medicinename2" placeholder="请输入" style="width:60%; float: right;"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px; width:28%;">每日次数</div>
								<div style="float:right; width:50px; font-size: 14px; text-align: right; padding-right: 20px;">次</div>
								<input id="daynum2" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每日"/>								
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px;">每次用量</div>
								<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="padding-right: 20px; float: right;">
									<input id='result4' class="ui-alert" placeholder="粒" style="width:30px; float: right; color:#000;"/>
								</a>
								<input id="num2" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每次"/>
							</div>
						</li>
					</div>
				</div>
			</ul>		
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; width:100%;">
								<div style="float:left; font-size: 16px;">药物名称3</div>
								<input class="ui-alert bottom_soild" id="medicinename3" placeholder="请输入" style="width:60%; float: right;"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px; width:28%;">每日次数</div>
								<div style="float:right; width:50px; font-size: 14px; text-align: right; padding-right: 20px;">次</div>
								<input id="daynum3" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每日"/>	
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px;">每次用量</div>
								<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="padding-right: 20px; float: right;">
									<input id='result5' class="ui-alert" placeholder="粒" style="width:30px; float: right; color:#000;"/>
								</a>
								<input id="num3" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每次"/>
							</div>
						</li>
					</div>
				</div>
			</ul>		
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; width:100%;">
								<div style="float:left; font-size: 16px;">其他药物</div>
								<input class="ui-alert bottom_soild" id="medicinename4" placeholder="请输入" style="width:60%; float: right;"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px; width:28%;">每日次数</div>
								<div style="float:right; width:50px; font-size: 14px; text-align: right; padding-right: 20px;">次</div>
								<input id="daynum4" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每日"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px;">每次用量</div>
								<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="padding-right: 20px; float: right;">
									<input id='result6' class="ui-alert" placeholder="粒" style="width:30px; float: right; color:#000;"/>
								</a>
								<input id="num4" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每次"/>
							</div>
						</li>
					</div>
				</div>
			</ul>	
			<ul class="mui-table-view diabetes" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; width:100%;">
								<div style="float:left; font-size: 16px;">胰岛素1</div>
								<input class="ui-alert bottom_soild" id="medicinename5" placeholder="请输入" style="width:60%; float: right;"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px; width:28%;">每日次数</div>
								<div style="float:right; width:50px; font-size: 14px; text-align: right; padding-right: 20px;">次</div>
								<input id="daynum5" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每日"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px;">每次用量</div>
								<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="padding-right: 20px; float: right;">
									<input id='result7' class="ui-alert" placeholder="粒" style="width:30px; float: right; color:#000;"/>
								</a>
								<input id="num5" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每次"/>
							</div>
						</li>
					</div>
				</div>
			</ul>	
			<ul class="mui-table-view diabetes" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; width:100%;">
								<div style="float:left; font-size: 16px;">胰岛素2</div>
								<input class="ui-alert bottom_soild" id="medicinename6" placeholder="请输入" style="width:60%; float: right;"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px; width:28%;">每日次数</div>
								<div style="float:right; width:50px; font-size: 14px; text-align: right; padding-right: 20px;">次</div>
								<input id="daynum6" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每日"/>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div style="float:left; width:100%; margin-top:6px;">
								<div style="float:left; font-size: 16px;">每次用量</div>
								<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="padding-right: 20px; float: right;">
									<input id='result8' class="ui-alert" placeholder="粒" style="width:30px; float: right; color:#000;"/>
								</a>
								<input id="num6" type="number" style="width:20%; float:right; text-align: right;" class="ui-alert bottom_soild"  placeholder="每次"/>
							</div>
						</li>
					</div>
				</div>
			</ul>
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
						<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 16px;">是否转诊</div>
							<div class="mui-switch" id="mySwitch2">
							  <div class="mui-switch-handle"></div>
							</div>
						</li>
						<li class="mui-table-view-cell" style="display: none;" id="tigshow_go">
							<div style="float: left; width:100%;">
								<div style="float: left; font-size: 16px; width:5rem; text-align:center;">原因</div>
								<input id="why" class="ui-alert"  placeholder="原因" style="width:60%; margin-left: 6px;"/>
							</div>
							<div style="float: left; width:100%; margin-top:6px;">
								<div style="float: left; font-size: 16px; width:5rem;">机构及级别</div>
								<input id="level" class="ui-alert"  placeholder="机构及级别" style="width:60%;  margin-left: 6px;"/>
							</div>
						</li>
					</div>
				</div>
			</ul>
			<div onclick="submit()" class="submit" >保存</div>
		</div>
		<script src="../js/mui.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<script src="../js/jquery.min-1.11.1.js"></script>
		<script src="../js/request.js"></script>
		<script type="text/javascript">
			//获取变量
			var self = localStorage.getItem("name")
			console.log(self)
			var dataold = JSON.parse(self)
			var obj = dataold.obj
			var selfdata ="";
			var listdata ="";
			mui.plusReady(function(){
				var self = plus.webview.currentWebview()
					listdata = self.data;
					visitId = self.visitdata;
					selfdata = JSON.parse(listdata)
					console.log(selfdata)
					console.log(selfdata.ehrId)
				var date1 = new Date();
				var year1=date1.getFullYear(); 
				var month1=date1.getMonth()+1;
				var day1=date1.getDate();
				var h1=date1.getHours();
				var m1=date1.getMinutes();
				var s1=date1.getSeconds();
					month1 =(month1<10 ? "0"+month1:month1); 
					day1 =(day1<10 ? "0"+day1:day1); 
					h1 =(h1<10 ? "0"+h1:h1); 
					m1 =(m1<10 ? "0"+m1:m1); 
					s1 =(s1<10 ? "0"+s1:s1);
					createDate = (year1.toString()+'-'+month1.toString()+'-'+day1.toString()+' '+h1.toString()+':'+m1.toString()+':'+s1.toString());
					modifyDate = (year1.toString()+'-'+month1.toString()+'-'+day1.toString()+' '+h1.toString()+':'+m1.toString()+':'+s1.toString());
					ehrId = selfdata.ehrId;
				if(self.second != ""){
					first = JSON.parse(self.first);
					second = JSON.parse(self.second);
					id = first.id;
					createUser = first.createUser;
					createDate = first.createDate;
					console.log(self.second);
					for(var i=0; i<second.length; i++){
						if(second[i].questionId == "329"){
							var rowsmedicine=resultall.r1
							for(var j=0; j<rowsmedicine.length; j++){
								if(second[i].answerId == rowsmedicine[j].id){
									document.getElementById("medicine").value = rowsmedicine[j].text;
								}
							}
						}
						if(second[i].questionId == "330"){
							console.log(second[i].answerId)
							if(second[i].answerId == "55"){
								document.getElementById("tigshow").style.display="block";
								document.getElementById("mySwitch").classList.add('mui-active');
								reactions ="55";
							}else{
								document.getElementById("tigshow").style.display="none";
								document.getElementById("mySwitch").classList.remove('mui-active');
								reactions ="56";
							}
						}
						if(second[i].questionId == "337"){
							document.getElementById("medicinename").value = second[i].answer;
						}
						if(second[i].questionId == "481"){
							var rowsthetype=resultall.r2
							for(var j=0; j<rowsthetype.length; j++){
								if(second[i].answerId == rowsthetype[j].id){
								document.getElementById("lbstype").value = rowsthetype[j].text;
								}
							}
						}
						if(second[i].questionId == "331"){
							var rowsthetype=resultall.r3
							for(var j=0; j<rowsthetype.length; j++){
								if(second[i].answerId == rowsthetype[j].id){
								document.getElementById("thetype").value = rowsthetype[j].text;
								}
							}
						}
						if(second[i].questionId == "342"){
							document.getElementById("medicinename1").value = second[i].answer;
						}
						if(second[i].questionId == "346"){
							document.getElementById("daynum1").value = second[i].answer;
						}
						if(second[i].questionId == "350"){
							document.getElementById("num1").value = second[i].answer;
						}
						if(second[i].questionId == "485"){
							var rowsnum1unit=resultall.r4
							document.getElementById("result3").value = rowsnum1unit[second[i].answerId];
						}
						if(second[i].questionId == "343"){
							document.getElementById("medicinename2").value = second[i].answer;
						}
						if(second[i].questionId == "347"){
							document.getElementById("daynum2").value = second[i].answer;
						}
						if(second[i].questionId == "351"){
							document.getElementById("num2").value = second[i].answer;
						}
						if(second[i].questionId == "486"){
							var rowsnum2unit=resultall.r4
							document.getElementById("result4").value = rowsnum2unit[second[i].answerId];
						}
						if(second[i].questionId == "344"){
							document.getElementById("medicinename3").value = second[i].answer;
						}
						if(second[i].questionId == "348"){
							document.getElementById("daynum3").value = second[i].answer;
						}
						if(second[i].questionId == "352"){
							document.getElementById("num3").value = second[i].answer;
						}
						if(second[i].questionId == "487"){
							var rowsnum3unit=resultall.r4
							document.getElementById("result5").value = rowsnum3unit[second[i].answerId];
						}
						if(second[i].questionId == "345"){
							document.getElementById("medicinename4").value = second[i].answer;
						}
						if(second[i].questionId == "349"){
							document.getElementById("daynum4").value = second[i].answer;
						}
						if(second[i].questionId == "353"){
							document.getElementById("num4").value = second[i].answer;
						}
						if(second[i].questionId == "488"){
							var rowsnum4unit=resultall.r4
							document.getElementById("result6").value = rowsnum4unit[second[i].answerId];
						}
						if(second[i].questionId == "475"){
							document.getElementById("medicinename5").value = second[i].answer;
						}
						if(second[i].questionId == "477"){
							document.getElementById("daynum5").value = second[i].answer;
						}
						if(second[i].questionId == "479"){
							document.getElementById("num5").value = second[i].answer;
						}
						if(second[i].questionId == "489"){
							var rowsnum5unit=resultall.r4
							document.getElementById("result7").value = rowsnum5unit[second[i].answerId];
						}
						if(second[i].questionId == "476"){
							document.getElementById("medicinename6").value = second[i].answer;
						}
						if(second[i].questionId == "478"){
							document.getElementById("daynum6").value = second[i].answer;
						}
						if(second[i].questionId == "480"){
							document.getElementById("num6").value = second[i].answer;
						}
						if(second[i].questionId == "490"){
							var rowsnum6unit=resultall.r4
							document.getElementById("result8").value = rowsnum6unit[second[i].answerId];
						}
						if(second[i].questionId == "332"){
							console.log(second[i].answerId)
							if(second[i].answerId == "8"){
								document.getElementById("tigshow_go").style.display="block";
								document.getElementById("mySwitch2").classList.add('mui-active');
								referral ="8";
							}else{
								document.getElementById("tigshow_go").style.display="none";
								document.getElementById("mySwitch2").classList.remove('mui-active');
								referral ="9";
							}
						}
						if(second[i].questionId == "333"){
							document.getElementById("why").value = second[i].answer;
						}
						if(second[i].questionId == "334"){
							document.getElementById("level").value = second[i].answer;
						}
					}
				}
			})
			//赋值
			var resultall = {"r1":[{id:'0',text:' '},{id:'245',text:'规律'},{id:'246',text:'间断'},{id:'247',text:'不服药'}],
							"r2":[{id:'0',text:' '},{id:'360',text:'无'},{id:'361',text:'偶尔'},{id:'362',text:'频繁'}],
							"r3":[{id:'0',text:' '},{id:'284',text:'控制满意'},{id:'285',text:'控制不满意'},{id:'286',text:'不良反应'},{id:'287',text:'并发症'}],
							"r4":['','mg','ml','片','粒','u','g','iu','ug','ng','l']}
			var id = 0;
			var visitId= 0;
			var ehrId = "";
			var manageId = 0;
			var createUser = obj.id;
			var createDate = "";
			var modifyUser = obj.id;
			var modifyDate = "";
			var medicine = "";
			var lbstype = "";
			var thetype = "";
			var num1unit = "";
			var num2unit = "";
			var num3unit = "";
			var num4unit = "";
			var num5unit = "";
			var num6unit = "";
			var reactions ="56";
			var referral ="9";
				mui.init()
				(function($) {
				$.init();
				var result = $('#result')[0];
				var btns = $('.btn');
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var _self = this;
						if(_self.picker) {
							_self.picker.show(function (rs) {
								result.innerText = rs.text;
								_self.picker.dispose();
								_self.picker = null;
							});
						} else {
							if(i == 0){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'0',id:'245',text:'规律'},{value:'1',id:'246',text:'间断'},{value:'2',id:'247',text:'不服药'}]);
								 picker.show(function (selectItems) {
									$('#medicine')[0].value = selectItems[0].text;
									medicine = selectItems[0].id;
								  })
							}else if(i == 1){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'0',id:'360',text:'无'},{value:'1',id:'361',text:'偶尔'},{value:'2',id:'362',text:'频繁'}]);
								 picker.show(function (selectItems) {
									$('#lbstype')[0].value = selectItems[0].text;
									lbstype=selectItems[0].id;
								  })
							}else if(i == 2){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'0',id:'284',text:'控制满意'},{value:'1',id:'285',text:'控制不满意'},{value:'2',id:'286',text:'不良反应'},{value:'3',id:'287',text:'并发症'}]);
								 picker.show(function (selectItems) {
									$('#thetype')[0].value = selectItems[0].text;
									thetype=selectItems[0].id;
								  })
							}else if(i == 3){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'mg'},{value:'2',text:'ml'},{value:'3',text:'片'},{value:'4',text:'粒'},{value:'5',text:'u'},{value:'6',text:'g'},{value:'7',text:'iu'},{value:'8',text:'ug'},{value:'9',text:'ng'},{value:'10',text:'l'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 num1unit=selectItems[0].id;
								  })
							}else if(i == 4){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'mg'},{value:'2',text:'ml'},{value:'3',text:'片'},{value:'4',text:'粒'},{value:'5',text:'u'},{value:'6',text:'g'},{value:'7',text:'iu'},{value:'8',text:'ug'},{value:'9',text:'ng'},{value:'10',text:'l'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 num2unit=selectItems[0].id;
								  })
							}else if(i == 5){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'mg'},{value:'2',text:'ml'},{value:'3',text:'片'},{value:'4',text:'粒'},{value:'5',text:'u'},{value:'6',text:'g'},{value:'7',text:'iu'},{value:'8',text:'ug'},{value:'9',text:'ng'},{value:'10',text:'l'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 num3unit=selectItems[0].id;
								  })
							}else if(i == 6){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'mg'},{value:'2',text:'ml'},{value:'3',text:'片'},{value:'4',text:'粒'},{value:'5',text:'u'},{value:'6',text:'g'},{value:'7',text:'iu'},{value:'8',text:'ug'},{value:'9',text:'ng'},{value:'10',text:'l'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 num4unit=selectItems[0].id;
								  })
							}else if(i == 7){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'mg'},{value:'2',text:'ml'},{value:'3',text:'片'},{value:'4',text:'粒'},{value:'5',text:'u'},{value:'6',text:'g'},{value:'7',text:'iu'},{value:'8',text:'ug'},{value:'9',text:'ng'},{value:'10',text:'l'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 num5unit=selectItems[0].id;
								  })
							}else if(i == 8){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'mg'},{value:'2',text:'ml'},{value:'3',text:'片'},{value:'4',text:'粒'},{value:'5',text:'u'},{value:'6',text:'g'},{value:'7',text:'iu'},{value:'8',text:'ug'},{value:'9',text:'ng'},{value:'10',text:'l'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 num6unit=selectItems[0].id;
								  })
							}else{
								var optionsJson = this.getAttribute('data-options') || '{}';
								var options = JSON.parse(optionsJson);
								var id = this.getAttribute('id');
								/*
								 * 首次显示时实例化组件
								 * 示例为了简洁，将 options 放在了按钮的 dom 上
								 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker
								 */
								_self.picker = new $.DtPicker(options);
								_self.picker.show(function(rs) {
									/*
									 * rs.value 拼合后的 value
									 * rs.text 拼合后的 text
									 * rs.y 年，可以通过 rs.y.vaue 和 rs.y.text 获取值和文本
									 * rs.m 月，用法同年
									 * rs.d 日，用法同年
									 * rs.h 时，用法同年
									 * rs.i 分（minutes 的第二个字母），用法同年
									 */
									result.value = rs.text;
									/* 
									 * 返回 false 可以阻止选择框的关闭
									 * return false;
									 */
									/*
									 * 释放组件资源，释放后将将不能再操作组件
									 * 通常情况下，不需要示放组件，new DtPicker(options) 后，可以一直使用。
									 * 当前示例，因为内容较多，如不进行资原释放，在某些设备上会较慢。
									 * 所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例。
									 */
									_self.picker.dispose();
									_self.picker = null;
								});
							}
						}
						
					}, false);
				});
			})(mui);
			//开关事件
			mui('.mui-switch')['switch']()
			
			//切换
			document.getElementById("mySwitch").addEventListener("toggle",function(event){
				if(event.detail.isActive){
					document.getElementById("tigshow").style.display="block";
					reactions ="55";
				}else{
					document.getElementById("tigshow").style.display="none";
					reactions ="56";
				}
			})
			//切换
			document.getElementById("mySwitch2").addEventListener("toggle",function(event){
				if(event.detail.isActive){
					document.getElementById("tigshow_go").style.display="block";
					referral ="8";
				}else{
					document.getElementById("tigshow_go").style.display="none";
					referral ="9";
				}
			})
			//提交
			function submit(){
				console.log(reactions.id)
				console.log(referral.id)
				if(reactions != "55"){
					document.getElementById("medicinename").value="";
				}
				if(referral != "8"){
					document.getElementById("why").value="";
					document.getElementById("level").value="";
				}
				var medicine_1 = $('#medicine')[0].value;
				for(var re=0; re<resultall.r1.length; re++){
					if(medicine_1 == resultall.r1[re].text){
						medicine = resultall.r1[re].id;
					}
				}	
				var lbstype_1 = $('#lbstype')[0].value;
				for(var re=0; re<resultall.r2.length; re++){
					if(lbstype_1 == resultall.r2[re].text){
						lbstype = resultall.r2[re].id;
					}
				}	
				var thetype_1 = $('#thetype')[0].value;
				for(var re=0; re<resultall.r3.length; re++){
					if(thetype_1 == resultall.r3[re].text){
						thetype = resultall.r3[re].id;
					}
				}	
				var num1unit_1 = $('#result3')[0].value;
				for(var re=0; re<resultall.r4.length; re++){
					if(num1unit_1 == resultall.r4[re]){
						num1unit = re;
					}
				}
				var num2unit_1 = $('#result4')[0].value;
				for(var re=0; re<resultall.r4.length; re++){
					if(num2unit_1 == resultall.r4[re]){
						num2unit = re;
					}
				}	
				var num3unit_1 = $('#result5')[0].value;
				for(var re=0; re<resultall.r4.length; re++){
					if(num3unit_1 == resultall.r4[re]){
						num3unit = re;
					}
				}	
				var num4unit_1 = $('#result6')[0].value;
				for(var re=0; re<resultall.r4.length; re++){
					if(num4unit_1 == resultall.r4[re]){
						num4unit = re;
					}
				}	
				var num5unit_1 = $('#result7')[0].value;
				for(var re=0; re<resultall.r4.length; re++){
					if(num5unit_1 == resultall.r4[re]){
						num5unit = re;
					}
				}	
				var num6unit_1 = $('#result8')[0].value;
				for(var re=0; re<resultall.r4.length; re++){
					if(num6unit_1 == resultall.r4[re]){
						num6unit = re;
					}
				}	
				var dataobj=[
					//服药依从性
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"329",
					"answerId":medicine,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//不良反应
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"330",
					"answerId":reactions,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//不良反应药物名称
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"337",
					"answerId":"0",
					"answer":mui("#medicinename")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//低血糖反应
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"481",
					"answerId":lbstype,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//随访类型
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"331",
					"answerId":thetype,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//药物名称1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"342",
					"answerId":"0",
					"answer":mui("#medicinename1")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每日次数1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"346",
					"answerId":"0",
					"answer":mui("#daynum1")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"350",
					"answerId":"0",
					"answer":mui("#num1")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量单位1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"485",
					"answerId":num1unit,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//药物名称2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"343",
					"answerId":"0",
					"answer":mui("#medicinename2")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每日次数2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"347",
					"answerId":"0",
					"answer":mui("#daynum2")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"351",
					"answerId":"0",
					"answer":mui("#num2")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量单位2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"486",
					"answerId":num2unit,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//药物名称3
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"344",
					"answerId":"0",
					"answer":mui("#medicinename3")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每日次数3
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"348",
					"answerId":"0",
					"answer":mui("#daynum3")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量3
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"352",
					"answerId":"0",
					"answer":mui("#num3")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量单位3
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"487",
					"answerId":num3unit,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//药物名称4
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"345",
					"answerId":"0",
					"answer":mui("#medicinename4")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每日次数4
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"349",
					"answerId":"0",
					"answer":mui("#daynum4")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量4
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"353",
					"answerId":"0",
					"answer":mui("#num4")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//每次用量单位4
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"488",
					"answerId":num4unit,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"475",
					"answerId":"0",
					"answer":mui("#medicinename5")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素每日次数1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"477",
					"answerId":"0",
					"answer":mui("#daynum5")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素每次用量1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"479",
					"answerId":"0",
					"answer":mui("#num5")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素每次用量单位1
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"489",
					"answerId":num5unit,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":"null",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"476",
					"answerId":"0",
					"answer":mui("#medicinename6")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素每日次数2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"478",
					"answerId":"0",
					"answer":mui("#daynum6")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素每次用量2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"480",
					"answerId":"0",
					"answer":mui("#num6")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//胰岛素每次用量单位2
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"490",
					"answerId":num6unit,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//是否转诊
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"332",
					"answerId":referral,
					"answer":null,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//原因
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"333",
					"answerId":"0",
					"answer":mui("#why")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser},
					//转诊级别
					{'id':id,
					'ehrId':ehrId,
					"manageId":manageId,
					"visitId":visitId,
					"questionId":"334",
					"answerId":"0",
					"answer":mui("#level")[0].value,
					"expectedAnswerId":"0",
					"expectedAnswer":null,
					"createDate":createDate,
					"modifyDate":modifyDate,
					"createUser":createUser,
					"modifyUser":modifyUser}
				] 
				$.ajax({
					type: 'post',
					url:getRequestUrl.url+"/mobile/ehr/DiabetesPersonAnswer/addOrUpdate",
					data:JSON.stringify(dataobj),
					dataType:"json",
					contentType : 'application/json;charset=utf-8',
					success : function(data) {
						if(data.status==1){
							alert("提交成功")
							mui.openWindow({
								url: 'follow_up_add.html', 
								id:'follow_up_add',
								extras:{
									
								}
							});
						}else{
							alert(data.message);
						}
					},
					error:function(xhr,type,errorThrown){
						
					}
				})
			}
		</script>
	</body>

</html>